package autoteam.ui.tabs;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

import autoteam.League;
import autoteam.Child;
import autoteam.tables.ChildPairTableModel;
import autoteam.ui.AutoTeamTablePanel;

public class AssignCarpoolsTab extends TabPanel
{   
    private static final long serialVersionUID = -8522122509375129945L;

    public AssignCarpoolsTab( final League doc, JFrame owner )
    {
	super();
	final ChildPairTableModel assignCarPoolModel = new ChildPairTableModel( doc, false );
	final AutoTeamTablePanel theTablePanel = new AutoTeamTablePanel( assignCarPoolModel );
	
	JComboBox comboBox = new JComboBox( doc.getChildren( ) );
	theTablePanel.setTableCellEditor( Child.class, comboBox );
	
	JButton guessButton = new JButton( "Guess" );
	guessButton.addActionListener( new ActionListener( )
	{
	    public void actionPerformed( ActionEvent e )
	    {
		theTablePanel.stopEditing( );
		doc.guessCarPools( );
		assignCarPoolModel.fireTableDataChanged( );
	    }
	} );
	
	theTablePanel.addButton( guessButton );
	this.add( theTablePanel );
    }

	public AssignCarpoolsTab( JFrame owner ) // testing only
	{
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void setButtonActions(JFrame parentFrame)
	{
		// TODO Auto-generated method stub
		
	}
}
